using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using PluginHandler;
using PluginHandler.UI;
using DatabaseManager.Util;

namespace DatabaseManager.UI
{
    /// <summary>
    /// The form, which displays several informations about the connection.
    /// The several informations are, e.g. the current database, the connection string, the connected server, ...
    /// </summary>
    public partial class FConnectionDetails : Form
    {
        private IPluginHandler _pluginHandler;

        /// <summary>
        /// Initializes a new instance of the <see cref="FConnectionDetails"/> class.
        /// </summary>
        /// <param name="plugin">The plugin.</param>
        public FConnectionDetails(IPluginHandler plugin)
        {
            InitializeComponent();

            _pluginHandler = plugin;

            //Loads the connection details control in the container
            ((IConnectionDetails)_pluginHandler.FormElements.ConnectionDetails).DatabaseConnection = _pluginHandler.DatabaseHandler.DatabaseConnection;
            _pluginHandler.FormElements.ConnectionDetails.Width = pnlConnectionDetailsContainer.Width;
            pnlConnectionDetailsContainer.Controls.Add(_pluginHandler.FormElements.ConnectionDetails);
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void FConnectionDetails_HelpButtonClicked(object sender, CancelEventArgs e)
        {
            Help.ShowHelp(
                this,
                Utility.GetHelpFileName(),
                HelpNavigator.TopicId,
                HelpTopics.FunctionsConnectionDetails);

            e.Cancel = true;
        }
    }
}